#!/usr/bin/env node

const http = require('http');

http.createServer((req, res) => {
  if (req.url = '/') {
    let html = "<html><meta charset='UTF-8'><body><h1>hello燕大</h1></body></html>";
    //res.writeHead(200, {
        //'Content-Type': 'text/html',
        //'Content-Lenght': Buffer.byteLength(html)
    //})
    res.setHeader('Content-Type', 'text/html');
    res.setHeader('Content-Length', `${Buffer.from(html).ByteLength}`)
    res.end(html)
  } else {
    res.statusCode = 404;
    res.setHeader('Content-Type', 'text/plain')
    res.end('Resource not found');
  }
}).listen(3000);
            
